<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="订单编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanBianhao"  >
              <a-input v-model="model.dingdanBianhao" placeholder="请输入订单编号"   disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="任务名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taskName">
              <a-input v-model="model.taskName" placeholder="请输入任务名称"  ></a-input>
            </a-form-model-item>
          </a-col>

          <a-col :span="6">
            <a-form-model-item label="订单类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanLeixing">
              <j-dict-select-tag type="list" v-model="model.dingdanLeixing" dictCode="dingdan_leixing" placeholder="请选择订单类型" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="接单人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanJiedanyuan">
              <j-select-user-by-dep v-model="model.dingdanJiedanyuan"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="客户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanKehu"  v-has="'shangwucaiwu'">
              <a-input v-model="model.dingdanKehu" placeholder="请输入客户/公司名称" :disabled="isDisabledAuth('dingdanxinxi')" v-has="'shangwucaiwu'" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="客户电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="kehuDianhua"  v-has="'shangwucaiwu'">
              <a-input v-model="model.kehuDianhua" placeholder="请输入客户联系方式" :disabled="isDisabledAuth('dingdanxinxi')"  v-has="'shangwucaiwu'"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6" >
            <a-form-model-item    label="客户税号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="kehuShuihao"  v-has="'shangwucaiwu'" >
              <a-input v-model="model.kehuShuihao" placeholder="请输入客户公司税号" style="width: 100%"   v-has="'shangwucaiwu'" :disabled="isDisabledAuth('dingdanxinxi')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="工期时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gongqiShijian">
              <j-date placeholder="请选择工期时间"  v-model="model.gongqiShijian" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"  />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6">
            <a-form-model-item label="订单状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanZhuangtai">
              <a-input v-model="model.dingdanZhuangtai" placeholder="请输入订单状态" disabled ></a-input>
            </a-form-model-item>
          </a-col>-->
          <a-col :span="6">
            <a-form-model-item label="订单材质" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanCaizhi">
              <j-dict-select-tag type="list" v-model="model.dingdanCaizhi" dictCode="dingdan_caizhi" placeholder="请选择订单材质" :disabled="isDisabledAuth('dingdanxinxi')" />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6">
            <a-form-model-item label="下单时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanXiadanshijian">
              <j-date placeholder="请选择下单时间"  v-model="model.dingdanXiadanshijian" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" />
            </a-form-model-item>
          </a-col>-->
          <a-col :span="6">
            <a-form-model-item label="模型重克" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanMoxingzhongliang">
              <a-input v-model="model.dingdanMoxingzhongliang" placeholder="请输入模型重克" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="模型件数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanShuliang">
              <a-input-number v-model="model.dingdanShuliang" placeholder="请输入模型件数" style="width: 100%"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="单克报价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dankeJine">
              <a-input v-model="model.dankeJine" placeholder="请输入单克金额报价"  :disabled="isDisabledAuth('dingdanxinxi')"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="预估金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanYuguJine"  v-has="'shangwucaiwu'">
              <a-input v-model="model.dingdanYuguJine" placeholder="请输入订单预估金额" style="width: 100%"  disabled  :disabled="isDisabledAuth('dingdanxinxi')"  v-has="'shangwucaiwu'"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item    label="实际金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanShijiJine"  v-has="'shangwucaiwu'">
              <a-input  v-has="'shangwucaiwu'" v-model="model.dingdanShijiJine" placeholder="请输入订单实际金额" style="width: 100%" :disabled="isDisabledAuth('dingdanxinxi')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item    label="设计金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shejiJine"  v-has="'shangwucaiwu'">
              <a-input v-has="'shangwucaiwu'" v-model="model.shejiJine" placeholder="请输入设计金额" style="width: 100%" :disabled="isDisabledAuth('dingdanxinxi')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="货款状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanHuokuan" >
              <j-dict-select-tag type="radio" v-model="model.dingdanHuokuan" dictCode="daikuan_status" placeholder="请选择货款状态"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="发货方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanFahuofangshi">
              <j-dict-select-tag type="radio" v-model="model.dingdanFahuofangshi" dictCode="fahuo_status" placeholder="请选择发货方式" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="15" > <!-- 修改了这里的span属性为6，offset属性为18 -->
            <a-form-model-item label="订单要求" prop="dingdanYaoqiu" :labelCol="{lg: {span: 3}, md: {span: 8}}" :wrapperCol="{lg: {span:21}, md: {span: 16} }" >
              <j-editor v-model="model.dingdanYaoqiu" />
            </a-form-model-item>
          </a-col>
          <a-col :span="9" > <!-- 修改了这里的span属性为18 -->
            <a-form-model-item label="模型图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dingdanTupian">
              <j-image-upload isMultiple v-model="model.dingdanTupian" ></j-image-upload>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>

            <a-col :lg="24" :md="24" >
              <a-divider>订单设计信息</a-divider>
            </a-col>
          <a-col :span="6">
            <a-form-model-item label="设计人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shejiRenyuan">
              <j-select-user-by-dep v-model="model.shejiRenyuan"  :disabled="isDisabledAuth('sheji')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="设计要求时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shejiRenyuanYaoqiuDate">
              <j-date placeholder="请选择设计要求时间"  v-model="model.shejiRenyuanYaoqiuDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('sheji')"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="设计完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shejiRenyuanWanchengDate">
              <j-date placeholder="请选择设计完成时间"  v-model="model.shejiRenyuanWanchengDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('sheji')"  />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6" v-has="'pingfen'">
            <a-form-model-item label="设计评分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shejiRenyuanPingfen">
              <j-dict-select-tag type="list" v-model="model.shejiRenyuanPingfen" dictCode="pingfen" placeholder="请选择设计评分"     />
            </a-form-model-item>
          </a-col>-->
          <a-col :span="6">
            <a-form-model-item label="设计拆件数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shejiCaijianShuliang">
              <a-input v-model="model.shejiCaijianShuliang" placeholder="请输入设计拆件数量"  :disabled="isDisabledAuth('sheji')" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :lg="24" :md="24" >
            <a-divider>订单生产信息：编程</a-divider>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="编程人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bianchengRenyuan">
              <j-select-user-by-dep v-model="model.bianchengRenyuan" :disabled="isDisabledAuth('biancheng')"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="编程要求时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bianchengRenyuanYaoqiuDate">
              <j-date placeholder="请选择编程要求时间"  v-model="model.bianchengRenyuanYaoqiuDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('biancheng')"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="编程完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bianchengRenyuanWanchengDate">
              <j-date placeholder="请选择编程完成时间"  v-model="model.bianchengRenyuanWanchengDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('biancheng')"  />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6" v-has="'pingfen'">
            <a-form-model-item label="编程评分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bianchengRenyuanPingfen">
              <j-dict-select-tag type="list" v-model="model.bianchengRenyuanPingfen" dictCode="pingfen" placeholder="请选择编程评分"   />
            </a-form-model-item>
          </a-col>-->
        </a-row>
        <a-col :lg="24" :md="24" >
          <a-divider>订单生产信息：上机</a-divider>
        </a-col>
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="上机人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shangjiRenyuan">
              <j-select-user-by-dep v-model="model.shangjiRenyuan" :disabled="isDisabledAuth('shangji')"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="上机要求时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shangjiRenyuanYaoqiuDate">
              <j-date placeholder="请选择上机要求时间"  v-model="model.shangjiRenyuanYaoqiuDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"  :disabled="isDisabledAuth('shangji')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="上机完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shangjiRenyuanWanchengDate">
              <j-date placeholder="请选择上机完成时间"  v-model="model.shangjiRenyuanWanchengDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('shangji')"  />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6"  v-has="'pingfen'">
            <a-form-model-item label="上机评分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shangjiRenyuanPingfen">
              <j-dict-select-tag type="list" v-model="model.shangjiRenyuanPingfen" dictCode="pingfen" placeholder="请选择上机评分"   />
            </a-form-model-item>
          </a-col>-->
          <a-col :span="6">
            <a-form-model-item label="下机拆件数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xiajiCaijianShuliang">
              <a-input v-model="model.xiajiCaijianShuliang" placeholder="请输入下机拆件数量" :disabled="isDisabledAuth('shangji ')"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-col :lg="24" :md="24" >
          <a-divider>订单生产信息：清洗</a-divider>
        </a-col>
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="清洗人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qingxiRenyuan">
              <j-select-user-by-dep v-model="model.qingxiRenyuan"  :disabled="isDisabledAuth('qingxi')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="清洗要求时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qingxiRenyuanYaoqiuDate">
              <j-date placeholder="请选择清洗要求时间"  v-model="model.qingxiRenyuanYaoqiuDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"  :disabled="isDisabledAuth('qingxi')"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="清洗完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qingxiRenyuanWanchengDate">
              <j-date placeholder="请选择清洗完成时间"  v-model="model.qingxiRenyuanWanchengDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('qingxi')" />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6"  v-has="'pingfen'">
            <a-form-model-item label="清洗评分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qingxiRenyuanPingfen">
              <j-dict-select-tag type="list" v-model="model.qingxiRenyuanPingfen" dictCode="pingfen" placeholder="请选择清洗评分"   />
            </a-form-model-item>
          </a-col>-->
          <a-col :span="6">
            <a-form-model-item label="清洗拆件数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qingxiCaijianShuliang">
              <a-input v-model="model.qingxiCaijianShuliang" placeholder="请输入清洗拆件数量"  :disabled="isDisabledAuth('qingxi')" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-col :lg="24" :md="24" >
          <a-divider>订单生产信息：打磨</a-divider>
        </a-col>
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="打磨人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="damoRenyuan">
              <j-select-user-by-dep v-model="model.damoRenyuan" :disabled="isDisabledAuth('damo')"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="打磨要求时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="damoRenyuanYaoqiuDate">
              <j-date placeholder="请选择打磨要求时间"  v-model="model.damoRenyuanYaoqiuDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"  :disabled="isDisabledAuth('damo')"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="打磨完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="damoRenyuanWanchengDate">
              <j-date placeholder="请选择打磨完成时间"  v-model="model.damoRenyuanWanchengDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"  :disabled="isDisabledAuth('damo')"/>
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6" v-has="'pingfen'">
            <a-form-model-item label="打磨评分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="damoRenyuanPingfen">
              <j-dict-select-tag type="list" v-model="model.damoRenyuanPingfen" dictCode="pingfen" placeholder="请选择打磨评分"    />
            </a-form-model-item>
          </a-col>-->
          <a-col :span="6">
            <a-form-model-item label="打磨拆件数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="damoCaijianShuliang">
              <a-input v-model="model.damoCaijianShuliang" placeholder="请输入打磨拆件数量"  :disabled="isDisabledAuth('damo')"></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-col :lg="24" :md="24" >
          <a-divider>订单生产信息：上色</a-divider>
        </a-col>
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="上色人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shangseRenyuan">
              <j-select-user-by-dep v-model="model.shangseRenyuan"   :disabled="isDisabledAuth('shangse')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="上色要求时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shangseRenyuanYaoqiuDate">
              <j-date placeholder="请选择上色要求时间"  v-model="model.shangseRenyuanYaoqiuDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"   :disabled="isDisabledAuth('shangse')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="上色完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shangseRenyuanWanchengDate">
              <j-date placeholder="请选择上色完成时间"  v-model="model.shangseRenyuanWanchengDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"    :disabled="isDisabledAuth('shangse')"/>
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6" v-has="'pingfen'">
            <a-form-model-item label="上色评分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shangseRenyuanPingfen">
              <j-dict-select-tag type="list" v-model="model.shangseRenyuanPingfen" dictCode="pingfen" placeholder="请选择上色评分"    />
            </a-form-model-item>
          </a-col>-->
          <a-col :span="6">
            <a-form-model-item label="上色拆件数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shangseCaijianShuliang">
              <a-input v-model="model.shangseCaijianShuliang" placeholder="请输入上色拆件数量"   :disabled="isDisabledAuth('shangse')"></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-col :lg="24" :md="24" >
          <a-divider>订单生产信息：装配</a-divider>
        </a-col>
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="装配人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zhuangpeiRenyuan">
              <j-select-user-by-dep v-model="model.zhuangpeiRenyuan" :disabled="isDisabledAuth('zuzhuang')"   />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="装配要求时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zhuangpeiRenyuanYaoqiuDate">
              <j-date placeholder="请选择装配要求时间"  v-model="model.zhuangpeiRenyuanYaoqiuDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('zuzhuang')"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="装配完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zhuangpeiRenyuanWanchengDate">
              <j-date placeholder="请选择装配完成时间"  v-model="model.zhuangpeiRenyuanWanchengDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('zuzhuang')"  />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6"  v-has="'pingfen'" >
            <a-form-model-item label="装配评分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zhuangpeiRenyuanPingfen">
              <j-dict-select-tag type="list" v-model="model.zhuangpeiRenyuanPingfen" dictCode="pingfen" placeholder="请选择装配评分"   />
            </a-form-model-item>
          </a-col>-->
          <a-col :span="6">
            <a-form-model-item label="组装拆件数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zuzhuangCaijianShuliang">
              <a-input v-model="model.zuzhuangCaijianShuliang" placeholder="请输入组装拆件数量"  :disabled="isDisabledAuth('zuzhuang')"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-col :lg="24" :md="24" >
          <a-divider>订单生产信息：质检</a-divider>
        </a-col>
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="质检人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zhijianRenyuan">
              <j-select-user-by-dep v-model="model.zhijianRenyuan"  :disabled="isDisabledAuth('shangwu')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="质检要求时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zhijianRenyuanYaoqiuDate">
              <j-date placeholder="请选择质检要求时间"  v-model="model.zhijianRenyuanYaoqiuDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('shangwu')"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="质检完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zhijianRenyuanWanchengDate">
              <j-date placeholder="请选择质检完成时间"  v-model="model.zhijianRenyuanWanchengDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('shangwu')" />
            </a-form-model-item>
          </a-col>
        </a-row>
<!--          <a-col :span="6" v-has="'pingfen'">
            <a-form-model-item label="质检评分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zhijianRenyuanPingfen">
              <j-dict-select-tag type="list" v-model="model.zhijianRenyuanPingfen" dictCode="pingfen" placeholder="请选择质检评分"   />
            </a-form-model-item>
          </a-col>-->
        <a-col :lg="24" :md="24" >
          <a-divider>订单生产信息：发货</a-divider>
        </a-col>
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="发货人员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fahuoRenyuan">
              <j-select-user-by-dep v-model="model.fahuoRenyuan"  :disabled="isDisabledAuth('shangwu')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="发货要求时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fahuoRenyuanYaoqiuDate">
              <j-date placeholder="请选择发货要求时间"  v-model="model.fahuoRenyuanYaoqiuDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="isDisabledAuth('shangwu')" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="发货完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fahuoRenyuanWanchengDate">
              <j-date placeholder="请选择发货完成时间"  v-model="model.fahuoRenyuanWanchengDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"  :disabled="isDisabledAuth('shangwu')" />
            </a-form-model-item>
          </a-col>
<!--          <a-col :span="6" v-has="'pingfen'">
            <a-form-model-item label="发货评分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fahuoRenyuanPingfen">
              <j-dict-select-tag type="list" v-model="model.fahuoRenyuanPingfen" dictCode="pingfen" placeholder="请选择发货评分"     />
            </a-form-model-item>
          </a-col>-->
          <a-col v-if="showFlowSubmitButton" :span="24" style="width: 100%;text-align: center;">
            <a-button icon="check" style="width: 126px" type="primary" @click="submitForm">提 交</a-button>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

import { httpAction, getAction, downFile } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'


  export default {
    name: 'TableDayinCopyForm',
    mixins: [DisabledAuthFilterMixin],
    components: {
    },
    props: {
      //流程表单data
      formData: {
        type: Object,
        default: ()=>{},
        required: false
      },
      //表单模式：true流程表单 false普通表单
      formBpm: {
        type: Boolean,
        default: false,
        required: false
      },
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
          dingdanMoxingzhongliang: '',
          dingdanShuliang: 0,
          dankeJine: '',
          dingdanYuguJine: '',
          dingdanBianhao: ''
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
    /*    validatorRules: {
           taskName: [
              { required: true, message: '请输入任务名称!'},
           ],
           dingdanJiedanyuan: [
              { required: true, message: '请输入接单员!'},
           ],
           dingdanKehu: [
              { required: true, message: '请输入客户名称!'},
           ],
           kehuDianhua: [
              { required: true, message: '请输入客户联系方式!'},
              { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
           ],
           dingdanYaoqiu: [
              { required: true, message: '请输入订单要求!'},
           ],
           dingdanXiadanshijian: [
              { required: true, message: '请输入下单时间!'},
           ],
           dingdanMoxingzhongliang: [
              { required: false},
              { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
           ],
           dingdanShuliang: [
              { required: true, message: '请输入模型件数!'},
              { pattern: /^-?\d+$/, message: '请输入整数!'},
           ],
           dingdanHuokuan: [
              { required: true, message: '请输入货款状态!'},
           ],
           shejiRenyuan: [
              { required: true, message: '请输入设计人员!'},
           ],
           shejiRenyuanYaoqiuDate: [
              { required: true, message: '请输入设计要求时间!'},
           ],
           shejiRenyuanWanchengDate: [
              { required: true, message: '请输入设计完成时间!'},
           ],
           shejiRenyuanPingfen: [
              { required: true, message: '请输入设计评分!'},
           ],
        },*/
        url: {
          add: "/dayincopy/tableDayinCopy/add",
          edit: "/dayincopy/tableDayinCopy/edit",
          queryById: "/dayincopy/tableDayinCopy/queryById",
          handlePrint: "/dayincopy/tableDayinCopy/handlePrint"
        }
      }
    },
    watch: {
      'model.dingdanMoxingzhongliang': 'calculateEstimatedAmount',
      'model.dingdanShuliang': 'calculateEstimatedAmount',
      'model.dankeJine': 'calculateEstimatedAmount'
    },
    computed: {
      formDisabled(){
        if(this.formBpm===true){
          if(this.formData.disabled===false){
            return false
          }
          return true
        }
        return this.disabled
      },
      showFlowSubmitButton(){
        if(this.formBpm===true){
          if(this.formData.disabled===false){
            return true
          }
        }
        return false
      }
    },
    created () {
      this.$nextTick(() => {
        this.generateOrderNumber();
      });
      var params = {id:this.formData.dataId};//查询条件
      getAction(this.url.queryById,params).then((res)=>{
        if(res.success){
          this.edit (res.result);
        }
      })
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
      //如果是流程中表单，则需要加载流程表单data
      this.showFlowData();

    },
    methods: {
      generateOrderNumber() {
        const now = new Date();
        const year = now.getFullYear();
        const month = String(now.getMonth() + 1).padStart(2, '0');
        const day = String(now.getDate()).padStart(2, '0');
        const hours = String(now.getHours()).padStart(2, '0');
        const minutes = String(now.getMinutes()).padStart(2, '0');
        const seconds = String(now.getSeconds()).padStart(2, '0');
        const randomNum = Math.floor(Math.random() * 1000); // 生成0到999之间的随机数
        const orderNumber = `SDYJ-${year}${month}${day}${hours}${minutes}${seconds}`;

        // 赋值给模型并输出日志
        this.model.dingdanBianhao = orderNumber;
        console.log("订单编号生成并赋值: ", this.model.dingdanBianhao);
      },
      calculateEstimatedAmount() {
        const { dingdanMoxingzhongliang, dingdanShuliang, dankeJine } = this.model;
        const weight = parseFloat(dingdanMoxingzhongliang) || 0;
        const quantity = parseFloat(dingdanShuliang) || 0;
        const pricePerGram = parseFloat(dankeJine) || 0;
        const estimatedAmount = weight * quantity * pricePerGram;
        this.model.dingdanYuguJine = estimatedAmount.toFixed(2); // 保留两位小数
      },
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      //打印导出
      handlePrint () {
        let params = {id:this.model.id};
       /* getAction(this.url.handlePrint,params).then((res)=>{
          if(res.success){
            this.edit (res.result);
          }
        });*/
         downFile(this.url.handlePrint,params).then((data)=>{
           if (!data || data.size === 0) {
             this.$message.warning('接单表下载失败！');
             return;
           }
           if (typeof window.navigator.msSaveBlob !== 'undefined') {
             window.navigator.msSaveBlob(new Blob([data], { type: 'application/msword' }), fileName + '.docx');
           }else{
             let url = window.URL.createObjectURL(new Blob([data], { type: 'application/msword' }));
             let link = document.createElement('a');
             link.style.display = 'none';
             link.href = url;
             link.setAttribute('download', this.model.id + '-接单表.docx');
             document.body.appendChild(link);
             link.click();
             document.body.removeChild(link); //下载完成移除元素
             window.URL.revokeObjectURL(url); //释放掉blob对象
           }
       }).finally(() => {
           this.confirmLoading = false;
         })
      },

      //渲染流程表单数据
      showFlowData(){
        if(this.formBpm === true){
          let params = {id:this.formData.dataId};
          getAction(this.url.queryById,params).then((res)=>{
            if(res.success){
              this.edit (res.result);
            }
          });
        }
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>